var menuLinks = [
    // {linkTitle: "key管理", linkName: "keypairs", linkDivided: true, roles: ["ROLE_USER"]},
    // {linkTitle: "控制台", linkName: "mconsole", linkDivided: true, roles: ["ROLE_USER"]},
    {linkTitle: "用户管理", linkName: "people", linkDivided: true, roles: ["ROLE_PERSON_MANAGER"]},
//    {linkTitle: "群组管理", linkName: "treenodes", linkDivided: true, roles: ["ROLE_PERSON_MANAGER"]},
    {linkTitle: "树管理", linkName: "trees", linkDivided: true, roles: ["ROLE_PERSON_MANAGER"]}
  ];

export default function menuFilter(userRecord) {
  if (!userRecord || !userRecord.get('roles')) {
    return menuLinks.filter(function(mit){
      return mit.roles.any(function(mrit){
        return mrit === "ROLE_ANONYMOUS";
      });
    });
  }

  var uroles = userRecord.get('roles');

  return menuLinks.filter(function(mit){
    return mit.roles.any(function(mrit){ //mrit is String
      return uroles.any(function(urit){ //urit is role Record.
        return urit.get('name') === mrit;
      });
    });
  });
}
